<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QXmlSerializer Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QXmlSerializer Class Reference<br /><sup><sup>[<a href="qtxmlpatterns.html">QtXmlPatterns</a> module]</sup></sup></h1><p>The QXmlSerializer class is an implementation of <a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a> for
transforming <a href="xmlprocessing.html">XQuery</a> output into
unformatted XML. <a href="#details">More...</a></p>

<p>Inherits <a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a>.</p><p>Inherited by <a href="qxmlformatter.html">QXmlFormatter</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qxmlserializer.html#QXmlSerializer">__init__</a></b> (<i>self</i>, QXmlQuery&#160;<i>query</i>, QIODevice&#160;<i>outputDevice</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#atomicValue">atomicValue</a></b> (<i>self</i>, QVariant&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#attribute">attribute</a></b> (<i>self</i>, QXmlName&#160;<i>name</i>, QStringRef&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#characters">characters</a></b> (<i>self</i>, QStringRef&#160;<i>value</i>)</li><li><div class="fn" />QTextCodec <b><a href="qxmlserializer.html#codec">codec</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#comment">comment</a></b> (<i>self</i>, QString&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#endDocument">endDocument</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#endElement">endElement</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#endOfSequence">endOfSequence</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#namespaceBinding">namespaceBinding</a></b> (<i>self</i>, QXmlName&#160;<i>nb</i>)</li><li><div class="fn" />QIODevice <b><a href="qxmlserializer.html#outputDevice">outputDevice</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#processingInstruction">processingInstruction</a></b> (<i>self</i>, QXmlName&#160;<i>name</i>, QString&#160;<i>value</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#setCodec">setCodec</a></b> (<i>self</i>, QTextCodec&#160;<i>codec</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#startDocument">startDocument</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#startElement">startElement</a></b> (<i>self</i>, QXmlName&#160;<i>name</i>)</li><li><div class="fn" /><b><a href="qxmlserializer.html#startOfSequence">startOfSequence</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QXmlSerializer class is an implementation of <a href="qabstractxmlreceiver.html">QAbstractXmlReceiver</a> for
transforming <a href="xmlprocessing.html">XQuery</a> output into
unformatted XML.</p>
<p>QXmlSerializer translates an <a href="qabstractxmlreceiver.html#xquery-sequence">XQuery sequence</a>,
usually the output of an <a href="qxmlquery.html">QXmlQuery</a>,
into XML. Consider the example:</p>
<pre class="cpp">
 <span class="type"><a href="qxmlquery.html">QXmlQuery</a></span> query;
 query<span class="operator">.</span>setQuery(<span class="string">"doc('index.html')/html/body/p[1]"</span>);

 <span class="type">QXmlSerializer</span> serializer(query<span class="operator">,</span> myOutputDevice);
 query<span class="operator">.</span>evaluateTo(<span class="operator">&amp;</span>serializer);
</pre>
<p>First it constructs a <a href="qxmlquery.html">query</a> that
gets the first paragraph from document <tt>index.html</tt>. Then it
constructs an instance of this class with the <a href="qxmlquery.html">query</a> and <a href="qiodevice.html">myOutputDevice</a>. Finally, it <a href="qxmlquery.html#evaluateTo">evaluates</a> the <a href="qxmlquery.html">query</a>, producing an ordered sequence of calls
to the serializer's callback functions. The sequence of callbacks
transforms the query output to XML and writes it to <a href="qiodevice.html">myOutputDevice</a>.</p>
<p>QXmlSerializer will:</p>
<ul>
<li>Declare namespaces when needed,</li>
<li>Use appropriate escaping, when characters can't be represented
in the XML,</li>
<li>Handle line endings appropriately,</li>
<li>Report errors, when it can't serialize the content, e.g., when
asked to serialize an attribute that is a top-level node, or when
more than one top-level element is encountered.</li>
</ul>
<p>If an error occurs during serialization, result is undefined
unless the serializer is driven through a call to <a href="qxmlquery.html#evaluateTo">QXmlQuery.evaluateTo</a>().</p>
<p>If the generated XML should be indented and formatted for
reading, use <a href="qxmlformatter.html">QXmlFormatter</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QXmlSerializer" />QXmlSerializer.__init__ (<i>self</i>, <a href="qxmlquery.html">QXmlQuery</a>&#160;<i>query</i>, <a href="qiodevice.html">QIODevice</a>&#160;<i>outputDevice</i>)</h3><p>Constructs a serializer that uses the name pool and message
handler in <i>query</i>, and writes the output to
<i>outputDevice</i>.</p>
<p><i>outputDevice</i> must be a valid, non-null device that is
open in write mode, otherwise behavior is undefined.</p>
<p><i>outputDevice</i> must not be opened with <a href="qiodevice.html#OpenModeFlag-enum">QIODevice.Text</a> because it
will cause the output to be incorrect. This class will ensure line
endings are serialized as according with the XML specification.
<a href="qxmlserializer.html">QXmlSerializer</a> does not take
ownership of <i>outputDevice</i>.</p>


<h3 class="fn"><a name="atomicValue" />QXmlSerializer.atomicValue (<i>self</i>, QVariant&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#atomicValue">QAbstractXmlReceiver.atomicValue</a>().</p>


<h3 class="fn"><a name="attribute" />QXmlSerializer.attribute (<i>self</i>, <a href="qxmlname.html">QXmlName</a>&#160;<i>name</i>, QStringRef&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#attribute">QAbstractXmlReceiver.attribute</a>().</p>


<h3 class="fn"><a name="characters" />QXmlSerializer.characters (<i>self</i>, QStringRef&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#characters">QAbstractXmlReceiver.characters</a>().</p>


<h3 class="fn"><a name="codec" /><a href="qtextcodec.html">QTextCodec</a> QXmlSerializer.codec (<i>self</i>)</h3><p>Returns the codec being used by the serializer for encoding its
XML output.</p>
<p><b>See also</b> <a href="qxmlserializer.html#setCodec">setCodec</a>().</p>


<h3 class="fn"><a name="comment" />QXmlSerializer.comment (<i>self</i>, QString&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#comment">QAbstractXmlReceiver.comment</a>().</p>


<h3 class="fn"><a name="endDocument" />QXmlSerializer.endDocument (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#endDocument">QAbstractXmlReceiver.endDocument</a>().</p>


<h3 class="fn"><a name="endElement" />QXmlSerializer.endElement (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#endElement">QAbstractXmlReceiver.endElement</a>().</p>


<h3 class="fn"><a name="endOfSequence" />QXmlSerializer.endOfSequence (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#endOfSequence">QAbstractXmlReceiver.endOfSequence</a>().</p>


<h3 class="fn"><a name="namespaceBinding" />QXmlSerializer.namespaceBinding (<i>self</i>, <a href="qxmlname.html">QXmlName</a>&#160;<i>nb</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#namespaceBinding">QAbstractXmlReceiver.namespaceBinding</a>().</p>


<h3 class="fn"><a name="outputDevice" /><a href="qiodevice.html">QIODevice</a> QXmlSerializer.outputDevice (<i>self</i>)</h3><p>Returns a pointer to the output device. There is no
corresponding function to <i>set</i> the output device, because the
output device must be passed to the constructor. The serializer
does not take ownership of its IO device.</p>


<h3 class="fn"><a name="processingInstruction" />QXmlSerializer.processingInstruction (<i>self</i>, <a href="qxmlname.html">QXmlName</a>&#160;<i>name</i>, QString&#160;<i>value</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#processingInstruction">QAbstractXmlReceiver.processingInstruction</a>().</p>


<h3 class="fn"><a name="setCodec" />QXmlSerializer.setCodec (<i>self</i>, <a href="qtextcodec.html">QTextCodec</a>&#160;<i>codec</i>)</h3><p>Sets the codec the serializer will use for encoding its XML
output. The output codec is set to <i>outputCodec</i>. By default,
the output codec is set to the one for <tt>UTF-8</tt>. The
serializer does not take ownership of the codec.</p>
<p><b>See also</b> <a href="qxmlserializer.html#codec">codec</a>().</p>


<h3 class="fn"><a name="startDocument" />QXmlSerializer.startDocument (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#startDocument">QAbstractXmlReceiver.startDocument</a>().</p>


<h3 class="fn"><a name="startElement" />QXmlSerializer.startElement (<i>self</i>, <a href="qxmlname.html">QXmlName</a>&#160;<i>name</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#startElement">QAbstractXmlReceiver.startElement</a>().</p>


<h3 class="fn"><a name="startOfSequence" />QXmlSerializer.startOfSequence (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractxmlreceiver.html#startOfSequence">QAbstractXmlReceiver.startOfSequence</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>